package com.orhon.smartcampus.modules.systemctl.mutation;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.orhon.smartcampus.basicComponents.Result;
import com.orhon.smartcampus.modules.systemctl.dao.OperationApiDao;

import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;

@Component
public class DeleteOperationApiMutation implements DataFetcher {


	@Autowired
	OperationApiDao operationApiDao;

    @Override
    public Object get(DataFetchingEnvironment environment) throws Exception {
        if (environment.getArgument("id") != null) {
            List<Integer> ids = environment.getArgument("id");
            for (Integer id : ids) {
            	operationApiDao.deleteById(Long.valueOf(id));
			}
            return Result.ok();
        }
        return Result.error();
    }
}

